package com.chenyaowei.happyhub.service.GoodsService;

import com.chenyaowei.happyhub.mapper.OrderMapper;
import com.chenyaowei.happyhub.pojo.GoodsPojo.Good;
import com.chenyaowei.happyhub.pojo.wechatuser.Order;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class OrderServiceImpl implements OrderService{
    @Resource
    OrderMapper orderMapper;

    @Override
    public List<Order> selectAllOrder() {
        return orderMapper.selectAllOrder();
    }

    @Override
    public Order selectOrderByOrderId(int id) {
        return orderMapper.selectOrderByOrderId(id);
    }

    @Override
    public void updateOrder(int id, String receiverName, String mobile, String province, String city, String detail) {
        orderMapper.updateOrder(id,receiverName,mobile,province,city,detail);
    }

    @Override
    public PageInfo searchOrder(int pageNum,int pageSize,String accountId, String keyword, String sort, String status) {
        PageHelper.startPage(pageNum, pageSize);
        List<Order> allOrderPresentList = orderMapper.searchOrder(accountId,keyword,sort,status);
        PageInfo<Order> pageInfo = new PageInfo<>(allOrderPresentList);
        return pageInfo;
    }

    @Override
    public List<Order> selectOrderByDate(String day, String goodId) {
        return orderMapper.selectOrderByDate(day,goodId);
    }
}
